package com.sunny.shop.api.v1;

import com.sunny.shop.bo.PageCounter;
import com.sunny.shop.model.Story;
import com.sunny.shop.service.StoryServiceImpl;
import com.sunny.shop.util.CommonUtil;
import com.sunny.shop.vo.PagingDozer;
import com.sunny.shop.vo.SongVO;
import com.sunny.shop.vo.StorySimplifyVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/story")
public class StoryController {

    @Autowired
    private StoryServiceImpl storyService;
    @GetMapping("/list/{cate_id}")
    public PagingDozer<Story,StorySimplifyVO> getStorys(@PathVariable Long cate_id,
                                 @RequestParam(defaultValue = "0") Integer page,
                                 @RequestParam(defaultValue = "10") Integer count){
//        PageCounter pageCounter = CommonUtil.converToParameter(start, count);
        Page<Story> storys = storyService.getStorys(cate_id, page, count);
        return new PagingDozer<>(storys, StorySimplifyVO.class);
    }

    @GetMapping("/detail/{id}")
    public List<SongVO> getStoryDetail(@PathVariable Long id){
        List<SongVO> storyDetail = storyService.getStoryDetail(id);
        return storyDetail;
    }
}
